using UnityEngine;
public class View : MonoBehaviour
{
    protected Logic logic;
    public virtual void Awake()
    {
        logic = this.GetComponent<Logic>();
    }
    public virtual void Start()
    {
    }
    private static RectTransform currentLoaddingWindow;
    public virtual void AddLoaddingWindow()
    {
        if (currentLoaddingWindow == null)
        {
            currentLoaddingWindow = CreateWindow("prefabs/LoaddingWindow");
        }
    }
    public virtual void RemoveLoaddingWindow()
    {
        if (currentLoaddingWindow != null)
        {
            Destroy(currentLoaddingWindow.gameObject);
        }
    }
    public virtual WindowView AddWindow(string path)
    {
        return CreateWindow(path).GetComponent<WindowView>();
    }
    public virtual RectTransform CreateWindow(string path)
    {
        GameObject window = Instantiate(Resources.Load(path)) as GameObject;
        RectTransform rectTransform = window.GetComponent<RectTransform>();
        rectTransform.SetParent(SceneView.currentScene.root);
        rectTransform.localScale = new Vector3(1, 1, 1);
        rectTransform.offsetMax = new Vector2(0, 0);
        rectTransform.offsetMin = new Vector2(0, 0);
        return rectTransform;
    }
}